<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Sound3D.pb</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font><font color="#006666">;   PureBasic - Sound3D
</font><font color="#006666">;
</font><font color="#006666">;    (c) Fantaisie Software
</font><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font>
<font color="#924B72">#CameraSpeed</font> = 1

<b><font color="#006666">IncludeFile</font></b> <font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Screen3DRequester.pb"

<b><font color="#006666">Define</font></b>.f KeyX, KeyY, MouseX, MouseY

<b><font color="#006666">If</font></b> <font color="#006666">InitEngine3D</font>()
  
<font color="#006666">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data", <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#006666">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Textures", <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#006666">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Models", <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#006666">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Scripts", <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#006666">  Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Packs/desert.zip", <font color="#924B72">#PB_3DArchive_Zip</font>)
<font color="#006666">  Parse3DScripts</font>()
  
<font color="#006666">  InitSprite</font>()
<font color="#006666">  InitKeyboard</font>()
<font color="#006666">  InitMouse</font>()
  
  <b><font color="#006666">If</font></b> <font color="#006666">Screen3DRequester</font>()
    
    <font color="#006666">;- Mesh
</font><font color="#006666">    CreateCube</font>(0, 100)
<font color="#006666">    CreateSphere</font>(1, 50)
    
    <font color="#006666">;- Material
</font><font color="#006666">    GetScriptMaterial</font>(0, "Color/Blue")
<font color="#006666">    GetScriptMaterial</font>(1, "Color/Red")
    
    <font color="#006666">;- Entity
</font><font color="#006666">    CreateEntity</font>(0,<font color="#006666"> MeshID</font>(0),<font color="#006666"> MaterialID</font>(0))
<font color="#006666">    CreateEntity</font>(1,<font color="#006666"> MeshID</font>(1),<font color="#006666"> MaterialID</font>(1))
        
    <font color="#006666">;- Sound3D
</font>    <b><font color="#006666">If</font></b> <font color="#006666">LoadSound3D</font>(0, "Roar.ogg")
<font color="#006666">      SoundVolume3D</font>(0, 50)
<font color="#006666">      SoundRange3D</font>(0, 1, 500)
<font color="#006666">      PlaySound3D</font>(0, <font color="#924B72">#PB_Sound3D_Loop</font>)
    <b><font color="#006666">EndIf</font></b>  
    
    <b><font color="#006666">If</font></b> <font color="#006666">LoadSound3D</font>(1, "Siren.ogg")
<font color="#006666">      SoundVolume3D</font>(1, 50)
<font color="#006666">      SoundRange3D</font>(1, 1, 500)
<font color="#006666">      PlaySound3D</font>(1, <font color="#924B72">#PB_Sound3D_Loop</font>)
    <b><font color="#006666">EndIf</font></b> 
    
    <font color="#006666">;- Node
</font>    <font color="#006666">; Create a node, so we can link the entity and the sound
</font><font color="#006666">    CreateNode</font>(0, -400, 0, 0)
<font color="#006666">      AttachNodeObject</font>(0,<font color="#006666"> SoundID3D</font>(0))
<font color="#006666">      AttachNodeObject</font>(0,<font color="#006666"> EntityID</font>(0))
      
    <font color="#006666">; Create a node, so we can link the entity and the sound
</font><font color="#006666">    CreateNode</font>(1, 400, 0, 0)
<font color="#006666">      AttachNodeObject</font>(1,<font color="#006666"> SoundID3D</font>(1))
<font color="#006666">      AttachNodeObject</font>(1,<font color="#006666"> EntityID</font>(1))
      
    <font color="#006666">;- Camera  
</font><font color="#006666">    CreateCamera</font>(0, 0, 0, 100, 100)
<font color="#006666">    MoveCamera</font>(0, -550, 70, 10, <font color="#924B72">#PB_Absolute</font>)
<font color="#006666">    CameraLookAt</font>(0,<font color="#006666"> NodeX</font>(1),<font color="#006666"> NodeY</font>(1),<font color="#006666"> NodeZ</font>(1)) 
    
    <font color="#006666">;- Light
</font><font color="#006666">    AmbientColor</font>(0)
<font color="#006666">    CreateLight</font>(0,<font color="#006666"> RGB</font>(255, 255, 255), 0, 700, 0)
    
    <font color="#006666">;- Sky
</font><font color="#006666">    SkyBox</font>("desert07.jpg")
    
    <b><font color="#006666">Repeat</font></b>
<font color="#006666">      Screen3DEvents</font>()
      
      <b><font color="#006666">If</font></b> <font color="#006666">ExamineMouse</font>()
        MouseX = -<font color="#006666">MouseDeltaX</font>() * <font color="#924B72">#CameraSpeed</font> * 0.05
        MouseY = -<font color="#006666">MouseDeltaY</font>() * <font color="#924B72">#CameraSpeed</font> * 0.05
      <b><font color="#006666">EndIf</font></b>
      
      <b><font color="#006666">If</font></b> <font color="#006666">ExamineKeyboard</font>()
        
        <b><font color="#006666">If</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Left</font>)
          KeyX = -<font color="#924B72">#CameraSpeed</font> 
        <b><font color="#006666">ElseIf</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Right</font>)
          KeyX = <font color="#924B72">#CameraSpeed</font> 
        <b><font color="#006666">Else</font></b>
          KeyX = 0
        <b><font color="#006666">EndIf</font></b>
                  
        <b><font color="#006666">If</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Up</font>)
          KeyY = -<font color="#924B72">#CameraSpeed</font> 
        <b><font color="#006666">ElseIf</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Down</font>)
          KeyY = <font color="#924B72">#CameraSpeed</font> 
        <b><font color="#006666">Else</font></b>
          KeyY = 0
        <b><font color="#006666">EndIf</font></b>

      <b><font color="#006666">EndIf</font></b>
           
<font color="#006666">      RotateCamera</font>(0, MouseY, MouseX, 0, <font color="#924B72">#PB_Relative</font>)
<font color="#006666">      MoveCamera  </font>(0, KeyX, 0, KeyY)
      
<font color="#006666">      SoundListenerLocate</font>(<font color="#006666">CameraX</font>(0),<font color="#006666"> CameraY</font>(0),<font color="#006666"> CameraZ</font>(0)) <font color="#006666">; The 'ear' follows the camera
</font>      
<font color="#006666">      RenderWorld</font>()

<font color="#006666">      FlipBuffers</font>()
    <b><font color="#006666">Until</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Escape</font>) <b><font color="#006666">Or</font></b> Quit = 1
  <b><font color="#006666">EndIf</font></b>
    
<b><font color="#006666">Else</font></b>
<font color="#006666">  MessageRequester</font>("Error", "The 3D Engine can't be initialized", 0)
<b><font color="#006666">EndIf</font></b>

<b><font color="#006666">End</font></b></font></pre>
</body></html>
